package aad.storyboard.model;

import java.util.ArrayList;

public class Scene extends StoryComponent{
	
	
	private ArrayList<Layer> layers=new ArrayList <Layer>();
	private ArrayList <Script> scripts=new ArrayList <Script> ();
	private Script currentScript=new Script();
	private int currentTime;
	
	private boolean isStarted=false;
	
	
	
	public Scene (int id){
		super(id);
	}

	public Scene(int id, int startTime) {
		super(startTime);
		layers = new ArrayList<Layer>();
		this.startTime=startTime;
		currentScript.setText("");
	}
	
	public Scene(int id, int startTime, int duration){
		super(id,startTime,startTime+duration);
		this.startTime = startTime;
		layers = new ArrayList<Layer>();
		currentScript.setText("");
	}
	
	public void setCurrentScript(Script text)
	{
		this.currentScript=text;
	}
	
	public Script getScript()
	{
		return currentScript;
	}
	
	public void setStartTime(int start) {
		this.startTime = start;
	}

	public int getStartTime() {
		return startTime;
	}
	
	public void addLayer(int layerNumber, Layer l)
	{
		this.layers.add(layerNumber,l);
	}
	
	public ArrayList<Layer> getLayerMap()
	{
		return layers;
	}
	
	public ArrayList<Layer> getLayers(){
		return layers;
	}
	
	public int getNumberOfLayers()
	{
	 return layers.size();
	}
	
	public Layer getLayer(int i)
	{
		return layers.get(i);
	}
	
	public boolean isStarted()
	{
		return isStarted;
	}

	public void setStarted()
	{
		isStarted=true;
	}

	public void setScripts(ArrayList <Script> scripts) {
		this.scripts = scripts;		
	}

	public ArrayList <Script> getScripts() {
		return scripts;
	}

	public void setCurrentTime(int currentTime) {
		this.currentTime = currentTime;
	}

	public int getCurrentTime() {
		return currentTime;
	}

	public void addScript(Script script) {
		this.scripts.add(script);
		
	}

	public boolean containsImage(String name) {
		for(Layer l : this.getLayers()){
			for(Image i : l.getImages()){
				if(i.getName().equals(name)){
					return true;
				}
			}
		}
		return false;
	}
	
	
}
